home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / pjc_asm.arc / PJ4-L3.ASM < prev    next >
Assembly Source File  |  1987-12-12  |  3KB  |  102 lines

  1. ; Listing 3.
  2. ; Program to illustrate operation of set/reset circuitry in conjunction
  3. ;  with CPU data to modify setting of memory that already contains data.
  4. ; Assembled with MASM 4.0, linked with LINK 3.51.
  5. ; Copyright by Michael Abrash, 4/26/87.
  6. ;
  7. stack    segment    para stack 'STACK'
  8.     db    512 dup(?)
  9. stack    ends
  10. ;
  11. EGA_VIDEO_SEGMENT    equ    0a000h    ;EGA display memory segment
  12. ;
  13. ; EGA register equates.
  14. ;
  15. TS_INDEX    equ    3c4h    ;TS index register
  16. TS_MAP_MASK    equ    2    ;TS map mask register
  17. GC_INDEX    equ    3ceh    ;GC index register
  18. GC_SET_RESET    equ    0    ;GC set/reset register
  19. GC_ENABLE_SET_RESET equ    1    ;GC enable set/reset register
  20. ;
  21. ; Macro to set indexed register INDEX of TS chip to SETTING.
  22. ;
  23. SETTS    macro    INDEX, SETTING
  24.     mov    dx,TS_INDEX
  25.     mov    al,INDEX
  26.     out    dx,al
  27.     inc    dx
  28.     mov    al,SETTING
  29.     out    dx,al
  30.     dec    dx
  31.     endm
  32. ;
  33. ; Macro to set indexed register INDEX of GC chip to SETTING.
  34. ;
  35. SETGC    macro    INDEX, SETTING
  36.     mov    dx,GC_INDEX
  37.     mov    al,INDEX
  38.     out    dx,al
  39.     inc    dx
  40.     mov    al,SETTING
  41.     out    dx,al
  42.     dec    dx
  43.     endm
  44. ;
  45. cseg    segment    para public 'CODE'
  46.     assume    cs:cseg
  47. start    proc    near
  48. ;
  49. ; Select 640x350 graphics mode.
  50. ;
  51.     mov    ax,010h
  52.     int    10h
  53. ;
  54.     mov    ax,EGA_VIDEO_SEGMENT
  55.     mov    es,ax            ;point to video memory
  56. ;
  57. ; Draw 18 10-scan-line high horizontal bars in green, 10 scan lines apart.
  58. ;
  59.     SETTS    TS_MAP_MASK,02h        ;map mask setting enables only
  60.                     ; plane 1, the green plane
  61.     sub    di,di        ;start at beginning of video memory
  62.     mov    al,0ffh
  63.     mov    bp,18        ;# bars to draw
  64. HorzBarLoop:
  65.     mov    cx,80*10    ;# bytes per horizontal bar
  66.     rep stosb        ;draw bar
  67.     add    di,80*10    ;point to start of next bar
  68.     dec    bp
  69.     jnz    HorzBarLoop
  70. ;
  71. ; Fill screen with alternating bars of red and brown, using CPU data
  72. ; to set plane 1 and set/reset to set planes 0, 2 & 3.
  73. ;
  74.     SETTS    TS_MAP_MASK,0fh        ;must set map mask to enable all
  75.                     ; planes, so set/reset values can
  76.                     ; be written to planes 0, 2 & 3
  77.                     ; and CPU data can be written to
  78.                     ; plane 1 (the green plane)
  79.     SETGC    GC_ENABLE_SET_RESET,0dh ;CPU data to planes 0, 2 & 3 will be
  80.                     ; replaced by set/reset value
  81.     SETGC    GC_SET_RESET,04h    ;set/reset value is 0ffh for plane 2
  82.                     ; (the red plane) and 0 for other
  83.                     ; planes
  84.     sub    di,di
  85.     mov    cx,80*350/2        ;# words per screen
  86.     mov    ax,07e0h        ;CPU data controls only plane 1;
  87.                     ; set/reset controls other planes
  88.     rep stosw            ;perform fill (affects all planes)
  89. ;
  90. ; Turn off set/reset.
  91. ;
  92.     SETGC    GC_ENABLE_SET_RESET,0
  93. ;
  94. ; Exit to DOS.
  95. ;
  96.     mov    ah,4ch
  97.     int    21h
  98. start    endp
  99. cseg    ends
  100.     end    start
  101.  
  102.